package com.macro.mall.tiny.controller;

import com.macro.mall.tiny.common.api.CommonResult;
import com.macro.mall.tiny.service.UmsMenberServcie;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ：czx
 * @date ：Created in 2021/7/10 17:59
 * @descriptioin:会员登录注册管理Controller
 * @modified By：
 */
@Slf4j
@Controller
@Api(tags = "UmsMemberController",description = "会员登录注册管理")
@RequestMapping("/sso")
public class UmsMemberController {
    private final static Logger LOGGER = LoggerFactory.getLogger(UmsMemberController.class);

        @Autowired
    private UmsMenberServcie umsMenberServcie;

    @ApiOperation("获取验证码")
    @RequestMapping(value = "/getAuthCode",method = RequestMethod.GET)
    @ResponseBody
    public CommonResult getAuthCode(@RequestParam String telephone){
        LOGGER.info("获取验证码,请求参数为: {}",telephone);
        //获取随机验证码
        CommonResult commonResult = umsMenberServcie.gennerateAuthCode(telephone);
        if (commonResult.getCode()!=200){
            LOGGER.error("获取验证码异常,异常信息为: {}",commonResult.getMessage());
            return commonResult;
        }
        LOGGER.info("获取验证码,返回参数为: {}",commonResult.getMessage());
        return commonResult;
    }


    @ApiOperation("判断验证码是否正确")
    @RequestMapping(value="/verifyAuthCode",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult verifyAuthCode(@RequestParam String telephone,@RequestParam String authCode){
            return umsMenberServcie.verifyAuthCode(telephone,authCode);
    }

}

























